package com.kimehwa.studyboot.elasticsearchtest;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @author xiaodongguan
 * @description
 * @since 2021-09-21 14:47
 */

public class Estest {
    /*
    增删改查都是要他进行搞起
     */
    public static void main(String[] args) throws IOException {

        // 创建es对象
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("47.105.163.178",9200,"http"))
        );
        // 创建索引
//        CreateIndexRequest user = new CreateIndexRequest("user");
//        CreateIndexResponse createIndexResponse = esClient.indices().create(user, RequestOptions.DEFAULT);

        GetIndexRequest user = new GetIndexRequest("user");
        GetIndexResponse getIndexResponse = esClient.indices().get(user, RequestOptions.DEFAULT);

        // 响应状态
//        boolean acknowledged = createIndexResponse.isAcknowledged();
//        System.out.println("索引操作：" +acknowledged);
        System.out.println(getIndexResponse.getAliases());
        System.out.println(getIndexResponse.getMappings());
        System.out.println(getIndexResponse.getSettings());


        esClient.close();



    }
}
